package com.acwing.partition11;

import java.io.*;

/**
 * @author `RKC`
 * @date 2021/12/10 16:06
 */
public class AC1017怪盗基德的滑翔翼 {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = reader.readLine().split("\\s+");
        int k = Integer.parseInt(s[0]);
        while (k-- > 0) {
            int n = Integer.parseInt(reader.readLine().split("\\s+")[0]);
            s = reader.readLine().split("\\s+");
            int[] heights = new int[n];
            for (int i = 0; i < n; i++) heights[i] = Integer.parseInt(s[i]);
            writer.write(dynamicProgramming(heights) + "\n");
        }
        writer.flush();
    }

    private static int dynamicProgramming(int[] heights) {
        //转化为LIS问题，如果选择i楼房，向左起跳相当于找到正序以heights[i]结尾的最长上升子序列；如果向右起跳相当于找到逆序以heights[i]结尾的最长上升子序列
        int answer = 1;
        int[] dp = new int[heights.length];
        for (int i = 0; i < heights.length; i++) {
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (heights[j] < heights[i]) dp[i] = Math.max(dp[i], dp[j] + 1);
                answer = Math.max(answer, dp[i]);
            }
        }
        for (int i = heights.length - 1; i >= 0; i--) {
            dp[i] = 1;
            for (int j = heights.length - 1; j > i; j--) {
                if (heights[j] < heights[i]) dp[i] = Math.max(dp[i], dp[j] + 1);
                answer = Math.max(answer, dp[i]);
            }
        }
        return answer;
    }
}
